package com.example.demo.config;

import com.example.demo.model.User;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.web.context.annotation.ApplicationScope;
import org.springframework.web.context.annotation.RequestScope;
import org.springframework.web.context.annotation.SessionScope;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Home-pc
 * Date: 2024-03-01
 * Time: 11:54
 */
@Configuration
public class BeanConfig {

    @Bean
    @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
    public User singleUser(){
        return new User();
    }

    @Bean
    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
    public User prototypeUser(){
        return new User();
    }

    @RequestScope
    @Bean("requestUser")
    public User requestUser(){
        return new User();
    }

    @SessionScope
    @Bean("sessionUser")
    public User sessionUser(){
        return new User();
    }

    @ApplicationScope
    @Bean("applicationUser")
    public User applicationUser(){
        return new User();
    }
}
